const arr1 = [1, 2, 2, 3, 4, 4];
const uniqueArr1 = [...new Set(arr1)];
console.log(uniqueArr1); // [1, 2, 3, 4]

function uniqueArray(arr) {
  const result = [];
  for (let i = 0; i < arr.length; i++) {
    if (result.indexOf(arr[i]) === -1) {
      result.push(arr[i]);
    }
  }
  return result;
}

// 测试
const arr = [1, 2, 2, 3, 4, 4];
console.log(uniqueArray(arr)); // [1, 2, 3, 4]
